import React, { Component } from 'react'
import Header from '../../components/Header/Header'
import { reqcartlist, reqgetgoods } from '../../http/api'
import { $pre } from "../../http/http"
export default class shop extends Component {
  constructor() {
    super()
    this.state = {
      arr: []
    }
  }

 componentDidMount() {
   this.getList()
  }

  async getList(){
    let res=await reqcartlist({
      uid:JSON.parse(sessionStorage.getItem("userInfo")).uid
    });
    if(res.data.code==200){
      let arr=res.data.list?res.data.list:[]
      // 补checked
      arr.forEach(item=>{
        item.checked=false
      })
      this.setState({
        arr,arr
      })
    }
  }

  render() {
    let { arr } = this.state
    console.log(arr);
    return (
      <div>
        <Header title="购物车"></Header>
          {
            arr.map((item ,index)=> {
              return <div key={index}>
                <img src={$pre + item.img} alt="" />
              </div>
            })
          }
      </div>
    )
  }
}
